<script type="text/javascript" src="/scripts/tabsheets.js"></script>


    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
        <tr>
       
          <td width="64%"><h1><?=$title?></h1></td>
          <td width="32%" valign="middle">
          <div style="padding-top:3em">
            <a onclick="displ(&#039;d1&#039;)" id="dd1" class="active">Картинками</a>
            <a onclick="displ(&#039;d2&#039;)" id="dd2" class="inactive">Cписком</a>
          </div>
        </td>
      </tr>
    </table>


<table width="100%" border="0" cellpadding="0" cellspacing="0" class="main" style="margin-top:1.2em">
  <tr>

    <td valign="top">
    

  <div id="d2" style="display:none;">
  <div style="padding-left:16%">
  
        <script type="text/javascript" src="/scripts/jquery.js"></script>
        <script type="text/javascript" src="/scripts/jquery.tablesorter.js"></script>
        <script type="text/javascript">
        $(function(){
          $("#catalog").tableSorter({
            sortClassAsc: 'headerSortUp', sortClassDesc: 'headerSortDown',
          headerClass: 'header' });
      })
      </script>
  
       <table id="catalog" cellspacing="0" width="60%" class="tablesorter">
        <thead>    
        <tr>
          <th width="1%">Производитель</th>
          <th>Модель</th>
          <th width="20%"><nobr>Цена, грн</nobr></th>
          
        </tr>
        </thead>
        
        <tbody>
  
          <? foreach ($all as $row){ 
       $query=$this->db->query("SELECT * FROM store WHERE id ='$row'");
       $row = $query->row();
       
       $father=$this->db->query("SELECT link FROM store WHERE id ='$row->father'");
       $father = $father->row();
       
      
        //Определяем цену/цены
		
		/*
        $price_min = $this->db->query("SELECT MIN(price) as price from articles where available=1 and father='$row->id' and price !=0");
        $price_max = $this->db->query("SELECT MAX(price) as price from articles where available=1 and father='$row->id'");
        $row_price_min = $price_min->row();
        $row_price_max = $price_max->row();
                 
                        if($row_price_min->price == $row_price_max->price && $row_price_max->price!=0){
                          $row_price_min->price = number_format($row_price_min->price, 0, ',', ' ');
                          $price=$row_price_min->price;
                        }else{
                          $row_price_min->price = number_format($row_price_min->price, 0, ',', ' ');
                          $row_price_max->price = number_format($row_price_max->price, 0, ',', ' ');
                          $price="$row_price_min->price" . "—" . "$row_price_max->price";
                        }
       */
	  
		$price=$this->Store_model->get_price($row->id);	  
       ?>
  

      
        <tr>
          <td valign="top"><?=$row->brand?></td>
          <td valign="top">
            <a href="/store/catalog/<?=$level1?>/<?=$level2?>/<?=$father->link?>/<?=$row->id?>/">
              <?=$row->name?></a>&nbsp;<?=$row->subhead?>
          </td>
          
          
          <td><?if($price !=0 || $price !="0—0"){echo "$price";}else{echo "<span style=\"color:white\">0</span>"; } ?></td>
       </tr>      
  
      <?}?>
      
   

        </tbody>
      </table>
      
   </div>
   </div>    
    
    
    
    
    <div id="d1">
    
    <? foreach ($all as $row){ 
       $query=$this->db->query("SELECT * FROM store WHERE id ='$row'");
       $row = $query->row();
       
       $father=$this->db->query("SELECT link FROM store WHERE id ='$row->father'");
       $father = $father->row();
       
    ?>
  
  
                    <?
                     //Определяем цену/цены
                     $price=$this->Store_model->get_price($row->id);
                    ?>  
                    
                    
                     <?if($this->uri->segment(3)== 'rods'){?>
                     
                    
                     
                     	<div>
                          <a href="/store/catalog/<?=$level1?>/<?=$level2?>/<?=$father->link?>/<?=$row->id?>/">
                             <div style="background: url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat bottom; height:120px;width:950px ">
                          <? if($row->action == '1'){ ?>
                          <img src="/images/global/act.png">
                          <?}?>
                           </div></a>
                       </div>
                       
                       <div>
                           <small><?=$row->subhead?></small>
                        </div>
                       
                           <div>
                               <small><? if($row->brand == 'RM'){ echo "«Рыболовный мир»";}else{ echo $row->brand;}?><a href="/store/catalog/<?=$level1?>/<?=$level2?>/<?=$father->link?>/<?=$row->id?>/"><?=$row->name?></a></small>
                            </div>
                           
                                         
                           <div style="margin-bottom:2em"><small>
                           <?if($price !=0)
                           
                               {echo "<b>$price грн</b>";}
                            else
                               {echo "<font color=\"gray\">Поставка ожидается</font>";}
                               
                           ?></small></div>
                     
                     
                     
                     
                     <?}else{?>
                     
                     
                     <div class="side">
                     	<a href="/store/catalog/<?=$level1?>/<?=$level2?>/<?=$father->link?>/<?=$row->id?>/">
                             <div style="background: url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat; height:200px;width:200px ">
                             <? if($row->action == '1'){ ?>
                             <img src="/images/global/act.png">
                             <?}?>
                             </div>
                            </a>                     
                           <div>
                             <? if($row->brand == 'RM'){ echo "«Рыболовный мир»";}else{ echo $row->brand;}?> <a href="/store/catalog/<?=$level1?>/<?=$level2?>/<?=$father->link?>/<?=$row->id?>/"><nobr><?=$row->name?></nobr></a>
                          </div>
                          
                          <div>
                              <small><?=$row->subhead?></small>
                           </div>
                           
                           <div>
                              <? if($price !=0){echo "<b>$price грн</b>";}else{echo "<span class='gray'>Поставка ожидается</span>";} ?>                                  
                           </div>
                     </div>
          
         
          <?}?>

          <? } ?>
    
  
    </div>
    
    </td>
  </tr>
</table>
